import sys
import numpy as np
import pyqtgraph as pg
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from PyQt5.QtCore import QTimer


class RealTimePlot(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle('Real-Time Plot')
        self.setGeometry(100,100,800,600)
        # 创建一个PyQtGraph绘图窗口
        Widget = pg.GraphicsLayoutWidget()
        self.setCentralWidget(Widget)

        plot = Widget.addPlot(title="Real")
        plot.showGrid(x=True, y=True)
        plot.setLabel('left', 'Y')
        plot.setLabel('bottom', 'X')

        # 生成初始数据
        x = np.linspace(0, 10, 100)
        y = np.sin(x)
        plot.plot(x, y)



if __name__ == '__main__':
    app = QApplication(sys.argv)
    Window = RealTimePlot()
    Window.show()
    sys.exit(app.exec_())
